package com.douwong.student.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.douwong.student.R;
import com.douwong.student.model.PrepareTitle;

import java.util.ArrayList;

/**
 * 导读列表适配器
 * @author leihuajie
 *
 */
public class FeaturesAdapter extends BaseAdapter {

	private Context context;
	private ArrayList<PrepareTitle>list;
	public FeaturesAdapter(Context context, ArrayList<PrepareTitle>list){
		this.context=context;
		this.list=list;
	}
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View view, ViewGroup parent) {
		Holder holder=null;
		if(view==null){
			holder=new Holder();
			view=LayoutInflater.from(context).inflate(R.layout.features_item, null);
			holder.title_text=(TextView) view.findViewById(R.id.title_text);
			holder.subject_text=(TextView) view.findViewById(R.id.subject_text);
			holder.createtime_text=(TextView) view.findViewById(R.id.create_time_text);
			view.setTag(holder);
		}else{
			holder=(Holder) view.getTag();
		}
		if(list.size()>0){
			holder.title_text.setText(list.get(position).getName());
			holder.subject_text.setText(list.get(position).getSubject());
			holder.createtime_text.setText(list.get(position).getCreateTime());
			
		}
		return view;
	}
	class Holder {
		TextView title_text,subject_text,createtime_text;
	}

}
